From 9444c07bdb26be151c6566fd703fa3b5c403e8d4 Mon Sep 17 00:00:00 2001 From: "smh22@firebug.cl.cam.ac.uk" Date: Thu, 6 Apr 2006 16:15:28 +0100 Subject: [PATCH] Fix long-standing save/restore bug on x86-64. Signed-off-by: Steven Hand --- .../drivers/xen/core/reboot.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c index 990dc35cee..ba0b9b9112 100644 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c @@ -85,6 +85,23 @@ void smp_resume(void); #define smp_resume() ((void)0) #endif +/* Ensure we run on the idle task page tables so that we will + switch page tables before running user space. This is needed + on architectures with separate kernel and user page tables + because the user page table pointer is not saved/restored. */ +static void switch_idle_mm(void) +{ + struct mm_struct *mm = current->active_mm; + + if (mm == &init_mm) + return; + + atomic_inc(&init_mm.mm_count); + switch_mm(mm, &init_mm, current); + current->active_mm = &init_mm; + mmdrop(mm); +} + static int __do_suspend(void *ignore) { int i, j, k, fpp, err; @@ -164,6 +181,8 @@ static int __do_suspend(void *ignore) time_resume(); + switch_idle_mm(); + __sti(); xencons_resume(); -- 2.30.2